<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="icon" type="text/css" href="icon.ico" />
    <?php foreach($conf['css'] as $k=>$v){ ?>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/{$v}.css" />
    <?php } ?>
    <script src="__PUBLIC__/Home/js/jquery-1.10.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script>
        var ajaxUpdateCart = "{:U('ajaxUpdateCart')}";
        var ajaxDelCartGoods = "{:U('ajaxDelCartGoods')}";
    </script>
    <?php foreach($conf['js'] as $k=>$v){ ?>
    <script src="__PUBLIC__/Home/js/{$v}.js" type="text/javascript" charset="utf-8"></script>
    <?php } ?>
</head>

<body>
<!--头部开始-->
<div id="top">
    <!--头部灰条就开始-->
    <div class="topbox">
        <div class="main">
            <div class="topleft fl">
                <a href="javascript:;">欢迎来到我的商城</a>
            </div>
            <div class="topright fr">
                <div class="login fl">
                    <?php if(session('home.uid')){ ?>
                            <a href="javascript:;">尊敬的{$_SESSION['home']['name']}欢迎回来！</a>
                            <a href="{:U('Home/Login/out')}">退出</a>
                    <?php }else{  ?>
                    <a href="{:U('Home/Login/login')}">你好，登录</a>
                    <a href="{:U('Home/Login/register')}">注册</a>
                    <?php } ?>
                </div>
                <span class="fl">|</span>
                <div class="fcode fl">
                    <?php if(!session('home.uid')){ ?>
                    <a href="{:U('Home/Login/login')}">我的订单</a>
                    <?php }else{ ?>
                    <a href="{:U('Home/MyCenter/index')}">我的订单</a>
                    <?php } ?>
                </div>
            </div>
        </div>
    </div>
    <!--头部灰条结束-->

    <!--载入页面是发送异步，获取购物车的商品数据-->
    <script>
      $(function () {
          $.post("{:U('Home/Cart/ajaxGetCartNum')}",{},function (res) {
//              如果为真就将获得的数据写入购物车内
                if(res){
                    $('#cart_num').text(res);
                }
          },'json')
          
      })
    </script>



    <!--logo区域开始-->
    <div class="logoRegion">
        <div class="main">
            <div class="logo">
                <a href="{:U('Home/Index/index')}"><img src="__PUBLIC__/Home/images/logo.jpg"/></a>
            </div>
            <div class="seachRegion">
                <div class="seach fl">
                    <form action="" method="post">
                        <input type="text" class="seachtxt fl" value="O2+车载空气净化" />
                        <input type="submit" class="btn" value="" />
                    </form>

                </div>
                <style>
                    #cart_num{
                        color: red;
                    }

                    .cart-tips ul {
                        padding:10px 20px;
                        overflow: hidden;
                    }
                    .cart-tips ul li{
                        overflow: hidden;
                        height:70px;
                        line-height:70px;
                        border-bottom: 1px solid #ccc;
                    }
                    .cart-tips ul li:last-child{
                        border:none;
                    }
                    .cart-tips  .pic {
                        float: left;
                    }
                    .cart-tips  .title a{
                        float: left;
                        color:#666;
                        width:142px;
                        overflow: hidden;
                        white-space:nowrap;
                        text-overflow:ellipsis;
                        margin-left: 10px;
                    }
                    .cart-tips  .price_num{
                        float: left;
                        margin-left: 30px;
                    }
                    .cart-tips  .delCartData{
                        color:red;
                        margin-right: 5px;
                    }

                </style>
                <div class="topshopcart fr">
                    <a href="{:U('cart/index')}" class="header-cart"><i></i>我的购物车<span class="cart-size">(<span id="cart_num">0</span>)</span></a>
                    <!--让购物车的高度自适应-->
                    <div class="cart-tips" style="height:auto;">
                        <ul>
                            <li style="text-align:center;">购物车中还没有商品~ 去 <a href="#" style="color:red;">购物</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <script>
                $(function () {
//                    给购物车加鼠标移入事件
                    $('.header-cart').mouseenter(function () {
//                        发送ajax获得购物车得数据
                        $.post('{:U("Home/Cart/ajaxGetCartData")}',{},function (res) {
//                            如果回调的res为真
                            if(res){
//                                定义一个空变量
                                var  str   =  '';
//                                循环遍历res
                                $.each(res,function (k,v) {
                                    str +=  '<li>'+
                                            '<a href="{:u(\'cart/index\')}" class="pic"><img src="__ROOT__/'+v.pic+'" width="50"></a>'+
                                            '<p class="title"><a href="{:u(\'cart/index\')}">'+v.name+'</a></p>'+
                                            '<p class="price_num">'+v.num+' X'+v.price+'</p>'+
                                            '<a href="javascript:;" class="delCartData" acid="'+v.acid+'" sid="'+k+'">X</a>' +
                                            '</li>'
                                })
                                str  =  '<ul>'+str+'</ul>';
//                              找到原来在（.cart-tips）的ul将替换为写好的数据
                                $('.header-cart').siblings('.cart-tips').find('ul').replaceWith(str);

                            }
                        },'json')
                        
                    })

//                    异步删除商品数据(属于未来元素)
                    $(document).on('click','.delCartData',function () {
//                        解决$(this)指向问题
                        var _this   = $(this);
//                        发送异步请求
                        $.post("{:U('Home/Cart/ajaxDelCartData')}",{acid:$(this).attr('acid'),sid:$(this).attr('sid')},function (res) {
                            if(res){
                                _this.parent().remove();
                            }
                        },'json')
                    })

                    
                })
            </script>

        </div>



        <!--{caid: "1", gid: "18", num: "1", price: "1099", gname: "魅族 魅蓝E 32GB 全网通公开版 月光银 移动联通电信4G手机",…}-->
    </div>
    <!--logo区域结束-->
    <!--导航开始-->
    <div class="navbox">
        <div class="main">
            <h5 class="fl"><a href=""><i></i>全部智能酷品</a></h5>
            <ul class="menu fl">
                <li class="menulist">
                    <a href="javascript:;">手机</a>
                    <div class="menuHiden">

                        <ul class="product">
                            <foreach name="goodsPhoneData" item="vo">
                            <li>
                                <span style="width:40px;text-overflow:ellipsis;white-space:nowrap;" class="title">{$vo['gname']}</span>
                                <a href="{:u('Home/Content/index',['gid'=>$vo['gid']])}"><img style="width: 120px;height: 110px;" src="__ROOT__/{$vo['pic']}" alt="" />
                                <p style="text-align: center;color: orange;">{$vo['shopprice']}元</p>
                            </li>
                            </foreach>

                        </ul>

                    </div>
                </li>

            </ul>

        </div>
        <block name="title"></block>
<!--尾部开始-->
<div class="mod-footer">
    <div class="foot-bannerw">
        <div class="foot-banner clearfix">
            <div class="banner-item">
                <a href="#" target="_blank" data-monitor="home_foot_days7"><i class="icon1">7</i>7天无理由退货</a>
            </div>
            <div class="banner-item">
                <a href="#" target="_blank" data-monitor="home_foot_days15"><i class="icon2">15</i>15天免费换货</a>
            </div>
            <div class="banner-item"><i class="icon3">包</i>满99元包邮</div>
            <div class="banner-item">
                <a href="#" target="_blank" data-monitor="home_foot_moblie"><i class="icon4">服</i>手机特色服务</a>
            </div>
        </div>
    </div>
    <div class="foot-containerw">
        <div class="foot-container clearfix">
            <dl class="foot-con"> <dt data-monitor="home_foot_freshman">友情衔接 </dt>
                <dd data-monitor="home_help_freshman">
                    <a target="_blank" href="http://c73_xiangpeng.52tty.com" rel="nofollow">我的个人展示页</a>
                </dd>
                <dd>
                    <a target="_blank" href="xiangpeng520.com" rel="nofollow">我的博客</a>
                </dd>
                <dd>
                    <a target="_blank" href="http://www.ruanyifeng.com" rel="nofollow">阮一峰博客</a>
                </dd>
                <dd>
                    <a target="_blank" href="http://baijunyao.com" rel="nofollow">白俊遥博客</a>
                </dd>
            </dl>
            <dl class="foot-con"> <dt data-monitor="home_foot_help">联系我</dt>
                <img src="__PUBLIC__/Home/images/weixin.png" alt="">
            </dl>
            <dl class="foot-con"> <dt data-monitor="home_foot_guide">联系我 </dt>
                <img src="__PUBLIC__/Home/images/qqt.png" alt="">
            </dl>

        </div>
    </div>
</div>
<!--尾部结束-->

<!--右边底部返回顶部-->
<div class="slidebar" id="slidebar">
    <ul>
        <li class="topback">
            <a href="javascript:;"></a>
        </li>
    </ul>
</div>
<!--右边底部返回顶部结束-->
</body>

</html>